package com.powerfl.frm.taf{
	
	internal class TAFparam{
		
		internal var vars:*;
		internal var param:Object;
		internal var tag:Array = [];
		internal var tween:Array = [];
		internal var bind:Array = [];
//		bind data sample
//		[
//			['bindDown', [ tree, flow, ...] ],
//			['bindUp', [ tree, flow, ...] ]
//		]
		
		public function TAFparam(){}
		internal function collect():TAFparam{
			if( vars is TAFawayVar ){
				TAF.SELF.poolCollectAwayVar( vars );
			}else if( vars is TAFtweenVar ){
				TAF.SELF.poolCollectTweenVar( vars );
			}
			vars = null;
			param = null;
			tween.length = 0;
			bind.length = 0;
			tag.length = 0;
			return this;
		}
		internal function addTag( $tag:String ):void{
			tag[tag.length] = $tag;
		}
		internal function addVar( $var:* ):void{
			vars = $var;
		}
		internal function addBind( $bind:Array ):void{
			bind[bind.length] = $bind;
		}
		internal function addParam( $param:Object ):void{
			var key:*
			if( param === null ){
				param = {};
			}
			for( key in $param ){
				param[key] = $param[key];
			}
		}
		internal function apply( $target:* ):void{
			applyVar( $target );
			applyParam( $target );
		}
		internal function applyVar( $target:* ):void{
			var key:*;
			if( vars ){
				vars.apply( $target );
			}
		}
		internal function applyParam( $target:* ):void{
			var key:*;
			if( param ){
				for( key in param ){
					if( param[key] === null ){}else{
						$target[key] = param[key];
					}
				}
			}
		}
		internal function applyBind( $tree:String ):void{
			var key:*;
			if( bind.length ){
				for each( key in bind ){
					key[1][0] = $tree;
					key[0].apply( null, key[1] );
				}
			}
		}
	}
}